<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class BannerList extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('banner_list', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('configId')->comment("广告表id");
            $table->text('imageUrl')->comment("广告图片");
            $table->string('name')->comment("广告名称");
            $table->string('url')->comment("跳转地址");
            $table->integer('startTime')->comment("开始时间");
            $table->integer('endTime')->comment("结束时间");
            $table->tinyInteger('status')->comment("图片状态,0:已上线，1：未上线");
            $table->tinyInteger('isDeleted')->default(0)->comment("是否删除，0：已删除，1：未删除");
            $table->integer('createdByUid')->default(0)->comment("创建人");
            $table->integer('updatedByUid')->default(0)->comment("修改人");
            $table->integer("createdAt")->comment("创建时间");
            $table->integer("updatedAt")->comment("修改时间");

            // 创建索引
            $table->unique('name');
            $table->collation = 'utf8mb4_general_ci';
        });

        $prefix = config('other.DB_PREFIX','');
        \Illuminate\Support\Facades\DB::statement("ALTER TABLE `{$prefix}banner_list` COMMENT = '广告横幅图片表'"); //表注释
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('banner_list');
    }
}
